#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>


int main(int argc, const char *argv[])
{
	int sockfd;
	struct sockaddr_in serveraddr,clientaddr;

	sockfd=socket(AF_INET,SOCK_STREAM,0);

	serveraddr.sin_family=AF_INET;
	serveraddr.sin_addr.s_addr=inet_addr(argv[1]);
	serveraddr.sin_port=htons(atoi(argv[2]));
	
	socklen_t addrlen=sizeof(serveraddr);

	connect(sockfd,(struct sockaddr *)&serveraddr,addrlen);
	
	char sndbuf[128];
	while(1)
	{		
		scanf("%s",sndbuf);
//		fgets(sndbuf,128,stdin);
//		getchar();
//		sndbuf[strlen(sndbuf)-1]='\0';
//		send(sockfd,sndbuf,128, 0);
		write(sockfd,sndbuf,128);
		memset(sndbuf,0,128);
	}
	return 0;
}
